#!/bin/bash
functions_compiler_included=true
if [ "$functions_base_included" = "" ]; then
file_name=functions-base.sh
funcs=`which $file_name`
if [ "$funcs" != "" ] ;then
  #echo "funcs=$funcs"
  . $funcs
else
  funcs=`dirname $0`/$file_name
  #echo "$PWD"
  #echo "funcs=$funcs"
  if [ "$funcs" != "" ] ;then
    . $funcs
  else
    exit
  fi
fi
fi


#function sh_get_build_id()                		#获取android 源代码的build id(姜饼,冰激凌)
#function sh_get_project_type()           		#判断项目类型 mtk 还是 qcom
#function sh_get_devl_type()               		#获取项目开发类型 判断是TD(技术开发) 还是 PD(产品开发)
#function sh_get_version_of_bbk()          		#获取bbk软件版本
#function sh_get_version_of_automake()     		#获取自动编译的软件版本
#function sh_get_version_of_modem()        		#获取 modem的版本信息
#function sh_get_product_name()            		#从列表中选择产品名称
#function sh_get_output_dirname_of_mtk_imgs() 	#获取mtk项目压缩包的名称
#function sh_get_output_dirname_of_qcom_imgs()  	#获取mtk项目压缩包的名称
#function sh_copy_mtk_output_files()       		#拷贝mtk输出结果到指定目录

#*********************************************************************************
#获取android 源代码的build id(姜饼,冰激凌)
#*********************************************************************************
function sh_get_build_id()
{
    local ac_build_id=
    echo $1 >&2
    ac_build_id="`cat ${1}/build/core/build_id.mk |grep BUILD_ID=`"
    echo ${ac_build_id##*=}
}

#*********************************************************************************
##判断项目类型 mtk 还是 qcom
#*********************************************************************************
function sh_get_project_type()
{
  local project_type=mtk
  local work_copy=$1
  if test  -d $work_copy; then
    if test -d $work_copy/mediatek/; then
      project_type=mtk
    elif test -d $work_copy/vendor/qcom/; then
      project_type=qcom
    else
      project_type=mtk
    fi
  fi
  echo "$project_type"
}


#*********************************************************************************
#获取项目开发类型 判断是TD(技术开发) 还是 PD(产品开发)
#*********************************************************************************
function sh_get_devl_type()
{
  local l_devl_type=TD
  local result=
  local project_name=$1
  if [ -n "$dev_name" ]; then
    dev_name=`echo $dev_name | tr '[A-Z]' '[a-z]'`
    result=`echo $dev_name |grep td`
    if [ -n "$result" ] ; then
      l_devl_type=TD
    else
    {
      result=`echo $dev_name |grep -E "pd"`
      if [ -n "$result" ] ; then
        l_devl_type=PD
      fi
    }
    fi
  fi
  echo "$l_devl_type"
}

#*********************************************************************************
#获取bbk软件版本
#*********************************************************************************
function sh_get_version_of_bbk() 
{
  local result=
  local work_copy=$1
  local product_name=$2
  local l_project_type=
  local version=
  local aaa=
  local bbb=

  if [ -z "$work_copy" ]; then
    work_copy=`pwd`
  fi
  if [ -z "$product_name" ]; then
    echo "$version"
    return
  fi
  l_project_type=`sh_get_project_type $work_copy`
  if [ "$l_project_type" = "mtk" ]; then
    if test -f $work_copy/mediatek/config/$product_name/ProjectConfig.mk; then
      result=`cat $work_copy/mediatek/config/$product_name/ProjectConfig.mk|grep ^BBK_PRODUCT_V |tr -d '='| awk '{print $2}'`
      if [ -n "$result" ]; then
        version="$result"
      fi
    else
      echo "$version"
    fi
  elif [ "$l_project_type" = "qcom" ]; then
    if test -f $work_copy/out/target/product/$product_name/system/build.prop; then
	  result=`cat $work_copy/out/target/product/$product_name/system/build.prop |grep ^ro.build.version.bbk | awk -F '=' '{print $2}'`
      if [ -n "$result" ]; then
        version="$result"
      fi
    else
      echo "$version"
    fi
  fi
  echo "$version"
}

#*********************************************************************************
#获取自动编译的软件版本
#*********************************************************************************
function sh_get_version_of_automake()
{
  local month=
  local day==
  local hour=
  local result=
  local work_copy=$1
  local product_name=$2
  local version=
  if [ -z "$work_copy" ]; then
    work_copy=`pwd`
  fi
  if [ -z "$product_name" ]; then
    echo "$version"
    return
  fi
  result=`sh_get_date_and_time2`
  month=`echo ${result:4:2}`
  day=`echo ${result:6:2}`
  hour=`echo ${result:8:2}`
  version="$month.$day.$hour"
  if test -f $work_copy/mediatek/config/$product_name/ProjectConfig.mk; then
    result=`cat $work_copy/mediatek/config/$product_name/ProjectConfig.mk|grep ^BBK_PRODUCT_V |tr -d '='| awk '{print $2}'| awk -F'_' '{print $1"_"$2}'`
    if [ -n "$result" ]; then
      echo "${result}_${version}"
    else
      echo "$version"
    fi
  else
    echo "$version"
  fi
}

function sh_format_time_of_automake()
{
  local month=
  local day==
  local hour=
  local result=
  local version=
  result=`sh_get_date_and_time2`
  month=`echo ${result:4:2}`
  day=`echo ${result:6:2}`
  hour=`echo ${result:8:2}`
  version="A$month.$day.$hour"
  echo "$version"
}

function sh_auto_version_mtk()
{
  local work_copy=$1
  local product_name=$2
  local bbk_version=$3
  local l_config_files=
  local l_version=
  if [ -z "$bbk_version" ]; then
     l_version=`sh_format_time_of_automake $work_copy $product_name`
     #编译成功的情况下，重新设置版本信息
     rm -rf $work_copy/mediatek/config/$product_name/ProjectConfig*.mk
     svn.shc up -q $work_copy/mediatek/config/$product_name/
     l_config_files=`ls $work_copy/mediatek/config/$product_name/ProjectConfig*.mk`
     for f in $l_config_files
     do
	aaaa=`cat $f |grep BBK_PRODUCT_VERSION |awk '{print $3}'`
	bbbb=`echo ${aaaa%_*}`
	cccc="${bbbb}_${l_version}"
        sh_sed_file_r_row_include_xxx $f "BBK_PRODUCT_VERSION" "BBK_PRODUCT_VERSION = $cccc"
        echo "old=$aaaa new=$cccc"
     done
   else
     rm -rf $work_copy/mediatek/config/$product_name/ProjectConfig*.mk
     svn.shc up -q $work_copy/mediatek/config/$product_name/
       l_config_files=`ls $work_copy/mediatek/config/$product_name/ProjectConfig*.mk`
       for f in $l_config_files
       do
	 aaaa=`cat $f |grep BBK_PRODUCT_VERSION |awk '{print $3}'`
	 bbbb=`echo ${aaaa%_*}`
	 cccc="${bbbb}_${bbk_version}"
         sh_sed_file_r_row_include_xxx $f "BBK_PRODUCT_VERSION" "BBK_PRODUCT_VERSION = $cccc"
         echo "old=$aaaa new=$cccc"
       done
   fi
}

function sh_auto_version_qcom()
{
  local work_copy=$1
  local product_name=$2
  local hardware=$3
  local bbk_version=$4
  local l_version=
  l_config_files="$work_copy/vendor/bbk/product/$hardware/bbk_product_config.mk"
  if [ -z "$bbk_version" ]; then
     l_version=`sh_format_time_of_automake $work_copy $product_name`
     #编译成功的情况下，重新设置版本信息
     rm -rf $l_config_files
     svn.shc up -q $l_config_files
     aaaa=`cat $l_config_files |grep BBK_PRODUCT_VERSION |awk '{print $3}'`
     bbbb=`echo ${aaaa%_*}`
     cccc="${bbbb}_${l_version}"
     sh_sed_file_r_row_include_xxx $l_config_files "BBK_PRODUCT_VERSION" "BBK_PRODUCT_VERSION = $cccc"
     echo "old=$aaaa new=$cccc"
   else
     rm -rf $l_config_files
     svn.shc up -q $l_config_files
     aaaa=`cat $l_config_files |grep BBK_PRODUCT_VERSION |awk '{print $3}'`
     bbbb=`echo ${aaaa%_*}`
     cccc="${bbbb}_${bbk_version}"
     sh_sed_file_r_row_include_xxx $l_config_files "BBK_PRODUCT_VERSION" "BBK_PRODUCT_VERSION = $cccc"
     echo "old=$aaaa new=$cccc"
   fi
}

#*********************************************************************************
#获取 modem的版本信息
#*********************************************************************************
function sh_get_version_of_modem()
{
  local version=
  local ac_modem_ver=
  local work_copy=$1
  local product_name=$2
  local l_project_type=mtk
  if [ -z "$work_copy" ]; then
    work_copy=`pwd`
  fi
  if [ -z "$product_name" ]; then
    echo "$version"
    return
  fi
  l_project_type=`sh_get_project_type $work_copy` 
  if [ "$l_project_type" = "mtk" ]; then
    ac_modem_ver=`strings ${work_copy}/out/target/product/${product_name}/system/etc/firmware/modem.img |grep MAUI |grep BIN`
    ac_modem_ver=${ac_modem_ver#*.} 
    ac_modem_ver=${ac_modem_ver%%.*}
    ac_modem_ver=`echo $ac_modem_ver|tr '_' '.'`
    ac_modem_ver=${ac_modem_ver#*.} 
    ac_modem_ver=${ac_modem_ver#*.} 
    version=${ac_modem_ver}
  fi
  echo "$version"
}

#*********************************************************************************
#从列表中选择产品名称
#*********************************************************************************
function sh_get_product_name()
{
  local product_name=
  local work_copy=$1
  if [ -n "$work_copy" ]; then
     if test -d $work_copy/mediatek/; then
        products_name=`ls $work_copy/mediatek/config/`
     else
        products_name=`ls $work_copy/device/qcom/`
     fi
  fi
  product_name=`sh_menu_select2 "$products_name"`
  echo "$product_name"
}

#*********************************************************************************
#获取mtk项目压缩包的名称
#*********************************************************************************
function sh_get_output_dirname_of_mtk_imgs() 
{
  local result=
  local work_copy=$1
  local product_name=$2
  local l_mode=manul
  local l_version=
  local l_project_type=
  local l_build_id=
  local l_framework_verion=
  local l_modem_version=
  local l_app_version
  local l_additional_info=
  if [ -n "$3" ]; then
    l_mode=$3
  fi

  if [ -z "$work_copy" ] || [ -z "$product_name" ]; then
    echo "$result"
    echo "work_copy product_name cant't be null" >&2
    return
  fi
  l_project_type=`sh_get_project_type $work_copy`
  l_version=`sh_get_version_of_bbk $work_copy $product_name`
  l_build_id=`sh_get_build_id $work_copy`
  if test -f $work_copy/.version; then
    l_framework_verion=`cat $work_copy/.version`
  else
    l_framework_verion=`sh_get_svn_committed_no_from_copy  $work_copy`
  fi
  if test -f $work_copy/packages/.version; then
    l_app_version=`cat $work_copy/packages/.version`
  else
    l_app_version=`sh_get_svn_committed_no_from_copy  $work_copy`
  fi 
  l_modem_version=`sh_get_version_of_modem $work_copy $product_name`
  if [ "$l_mode" == "mannul" ]; then
    l_framework_verion=`question  "输入框架的版本号:"  2 "$l_framework_verion"`
    l_app_version=`question  "输入应用版本号:"  2  "$l_app_version"`
    l_additional_info=`question  "输入补充信息:"  2 `
  fi
  if [ -n "$l_additional_info" ]; then
  l_additional_info=_${l_additional_info}
  fi
  result=${l_version}-${l_project_type}-${l_build_id}-${product_name}-r${l_framework_verion}-${l_modem_version}-appR${l_app_version}$l_additional_info
  echo "$result"
}

#*********************************************************************************
#获取mtk项目压缩包的名称
#*********************************************************************************
function sh_get_output_dirname_of_qcom_imgs() 
{
  local result=
  local work_copy=$1
  local product_name=$2
  local l_mode=manul
  local l_version=
  local l_project_type=
  local l_build_id=
  local l_framework_verion=
  local l_modem_version=
  local l_app_version
  local l_additional_info=
  if [ -n "$3" ]; then
    l_mode=$3
  fi

  if [ -z "$work_copy" ] || [ -z "$product_name" ]; then
    echo "$result"
    echo "work_copy product_name cant't be null" >&2
    return
  fi
  l_project_type=`sh_get_project_type $work_copy`
  l_version=`sh_get_version_of_bbk $work_copy $product_name`
  l_build_id=`sh_get_build_id $work_copy`
  if test -f $work_copy/.version; then
    l_framework_verion=`cat $work_copy/.version`
  else
    l_framework_verion=`sh_get_svn_committed_no_from_copy  $work_copy`
  fi
  if test -f $work_copy/packages/.version; then
    l_app_version=`cat $work_copy/packages/.version`
  else
    l_app_version=`sh_get_svn_committed_no_from_copy  $work_copy`
  fi 
  l_modem_version=`sh_get_version_of_modem $work_copy $product_name`
  if [ "$l_mode" == "mannul" ]; then
    l_framework_verion=`question  "输入框架的版本号:"  2 "$l_framework_verion"`
    l_app_version=`question  "输入应用版本号:"  2  "$l_app_version"`
    l_additional_info=`question  "输入补充信息:"  2 `
  fi
  if [ -n "$l_additional_info" ]; then
  l_additional_info=_${l_additional_info}
  fi
  result=${l_version}-${l_project_type}-${l_build_id}-${product_name}-r${l_framework_verion}-${l_modem_version}-appR${l_app_version}$l_additional_info
  echo "$result"
}

#*********************************************************************************
#拷贝mtk输出结果到指定目录
#*********************************************************************************
function sh_copy_mtk_output_files()
{
  local result=
  local work_copy=$1
  local product_name=$2
  local project_name=$3
  local output_dir=$4
  local product_name_lower=
  local version=
  local l_modem_dir=
  local l_output_dir=
  local l_tf_fatimg=
  local l_tf_fatimg_size=
  if [ -z "$work_copy" ]; then
    work_copy=`pwd`
  fi
  if [ -z "$product_name" ] || [ -z "$output_dir" ] ; then
    echoTextRed "!!必须指定项目名称和输出目录"
    return
  fi
  if [ -n "$output_dir" ]; then
    mkdir -pv $output_dir
  fi
  product_name_lower=`echo $product_name |tr A-Z  a-z`
  l_output_dir=$work_copy/out/target/product/$product_name/
  echoTextBlue  "拷贝mtk镜像文件 to $output_dir ......"
  #处理modem部分
  l_modem_dir=`cat $work_copy/mediatek/config/$product_name/ProjectConfig.mk |grep ^CUSTOM_MODEM |awk -F"=" '{print $2}'|tr -d '\r'|tr -d ' '`
  rm /tmp/sort -rf
  touch /tmp/sort
  tmp_files=`ls $work_copy/mediatek/custom/common/modem/$l_modem_dir/DbgInfo_* `
  for tmp in $tmp_files
  do
    aaaa="`basename $tmp`"
    bbbb=`echo ${aaaa:0-16}`
    echo "$bbbb" >> /tmp/sort
  done
  DbgInfo_file_t=`cat /tmp/sort  |sort  |tail -n 1`
  DbgInfo_file=`ls $work_copy/mediatek/custom/common/modem/$l_modem_dir/DbgInfo_* |grep $DbgInfo_file_t`
  echo "$work_copy/mediatek/custom/common/modem/$l_modem_dir/modem.info;"
  if test -f $work_copy/mediatek/custom/common/modem/$l_modem_dir/modem.info; then
   BPLGUInfo_file_t=`cat $work_copy/mediatek/custom/common/modem/$l_modem_dir/modem.info |grep MTK_BUILD_VERNO  |awk -F"=" '{print $2}' |tr -d ' '`
   BPLGUInfo_file_t=`echo $BPLGUInfo_file_t |tr '.' '_'`
   BPLGUInfo_file=`ls $work_copy/mediatek/custom/common/modem/$l_modem_dir/BPLGUInfo* |grep $BPLGUInfo_file_t`
  else
    echo "quit,没有modem.info，无法识别BPL数据库文件，拷贝过程退出"
    return
  fi

  #cgen_files=`ls $work_copy/mediatek/source/cgen/APDB_*`
  cgen_files=`find $work_copy/mediatek/ -type d -name ".svn" -prune -o -name "APDB_*" -print`
  copyfiles="$cgen_files $BPLGUInfo_file  $DbgInfo_file"
  for f in $copyfiles
  do 
    cp -rvf $f  $output_dir; 
  done
  sourceTargetFile="$work_copy/out/target/product/${product_name}/obj/PACKAGING/target_files_intermediates/${product_name}-target_files-*.zip"
  fullUpdateFile="$work_copy/out/target/product/${product_name}/${product_name}-ota-*.zip"
  l_android_imgs="boot.img rootboot.img recovery.img system.img userdata.img cache.img ramdisk-recovery.img ramdisk.img apps.img apps.zip"
#特殊处理fat.img
  l_tf_fatimg="$work_copy/${project_name}*.img"
  result=`ls $l_tf_fatimg | wc | awk '{print $1}'`
  if [ $result -le 1 ];then
	  if test -f $l_tf_fatimg;then
			l_tf_fatimg_size=`du -b $l_tf_fatimg | awk '{print $1}'`
			echo "l_tf_fatimg_size=$l_tf_fatimg_size"
			if [ ${l_tf_fatimg_size} -gt 5000000 ];then
				echo "fat.img存在，并且大于5M，使用此TF_fat.img"
				cp -rvf ${l_tf_fatimg} ${output_dir}/fat.img
			else
				echo "fat.img存在，但小于5M，使用默认的fat.img"
				l_android_imgs="${l_android_imgs} fat.img"
			fi

	  else
			echo "fat.img不存在，使用默认fat.img"
			l_android_imgs="${l_android_imgs} fat.img"
			echo "l_android_imgs=$l_android_imgs"
	  fi
  else
	  echoTextRed "根目录下有多于1个项目表的fat.img，请确认。必须只能为1个，打包退出"
	  exit
  fi
#特殊处理fat.img
  l_other_imgs="preloader_${product_name_lower}.bin DSP_BL uboot_${product_name_lower}.bin lk.bin secro.img logo.bin MBR EBR1 EBR2"
  l_config_files="*Android_scatter*.txt factory.ini  previous_build_config.mk"
  copyfiles2="$l_android_imgs $l_other_imgs $l_config_files $sourceTargetFile $fullUpdateFile"
  cd $l_output_dir
  for f in $copyfiles2
  do
    cp -rvfL $f  $output_dir; 
  done 
   
  if [ "$product_name" == "bbk77_cu_ics2" ] || [ "$product_name" == "bbk77_cu_jb" ] || [ "$product_name" == "bbk15_td_ics" ] || [ "$product_name" == "bbk15_td_ics2" ] ; then
	 kerlnelFile="$work_copy/kernel/out/vmlinux $work_copy/kernel/out/System.map"
  else
	 kerlnelFile="$work_copy/kernel/vmlinux $work_copy/kernel/System.map"
  fi

  if ! test -d $output_dir/kernel/;then
    mkdir $output_dir/kernel/
  fi
  for f in $kerlnelFile
  do
    cp -rvfL $f  $output_dir/kernel/; 
  done 

}

#*********************************************************************************
#初始化高通APQ8064源代码
#*********************************************************************************
function sh_init_apq8064_source()
{
  echoTextBlue "Initing apq8064 source ......"
  local zip_8064=
  local zip_9615=
  local zip_common=
  local top_dir=$1
  top_dir=${top_dir:-/tmp}
  local dir_8064=$top_dir/apq8064/8064
  local dir_9615=$top_dir/apq8064/8064-9615
ls |
while read name; do
na=$(echo $name | tr ' ' '_'|tr -d "()")
if [[ $name != $na ]]; then
mv "$name" $na
fi
done
  mkdir $dir_8064 $dir_9615 -pv
  for zip in `find.sh |grep zip`
  do
    result=`echo $zip |grep HY |grep -E "8064|9615"`
    if [ -n "$result" ]; then
      result=`echo $result |grep 8064`
      if [ -n "$result" ]; then
        zip_8064="$zip_8064 $result"
      else
        zip_9615="$zip_9615 $zip" 
      fi
    else
      zip_common="$zip_common $zip" 
    fi 
  done
  echo "zip_8064=$zip_8064"
  echo "zip_9615=$zip_9615"
  echo "zip_common=$zip_common"
  #解压缩处理开始
  for f in $zip_8064
  do
    result=`echo $f |grep APSS`
    if [ -z "$result" ]; then
      unzip -o $f -d $dir_8064
    fi
  done
  for f in $zip_9615
  do
    unzip -o $f -d $dir_9615
  done
  for f in $zip_common
  do
    result=`echo $f | grep lpass |grep 8064`
    if [ -n "$result" ]; then
      unzip -o $f -d $dir_8064
    fi
    result=`echo $f | grep lpass |grep 9615`
    if [ -n "$result" ]; then
      unzip -o $f -d $dir_9615
    fi
    if test -f `basename $f`; then
      result=`echo $f | grep HY`
      if [ -n "$result" ]; then
        unzip -o $f -d $dir_8064
        unzip -o $f -d $dir_9615
      fi
    fi
  done
  #解压缩处理结束
  #处理8064文件夹
  dirs=`ls $dir_8064/H*/* -d`
  for d in $dirs
  do
    if test -d $d; then
      mv $d $dir_8064
    fi
    result=`echo $d | grep contents`
    if [ -n "$result" ]; then
      mv $d $dir_8064
    fi
  done
  rm $dir_8064/H* -rf
  rm $dir_8064/*.pdf -rf
  mkdir $dir_8064/LINUX -pv
  mkdir nav_proc -pv
  #处理9615文件夹
  dirs=`ls $dir_9615/H*/* -d`
  for d in $dirs
  do
    if test -d $d; then
      mv $d $dir_9615
    else
      result=`echo $d | grep contents`
      if [ -n "$result" ]; then
        mv $d $dir_9615
      fi
    fi
  done
  rm $dir_9615/H* -rf
  rm $dir_9615/*.pdf -rf
  find $top_dir/apq8064 -name "*.sh" |xargs chmod  755
  find $top_dir/apq8064 -name "*.py" |xargs chmod  755
  find $top_dir/apq8064 -name "*.exe" |xargs chmod 755
}

#*********************************************************************************
#拷贝qcom输出结果到指定目录
#*********************************************************************************
function sh_copy_qcom_output_files()
{
  local result=
  local work_copy=$1
  local product_name=$2
  local output_dir=$3	 
  local product_name_lower=
  local version=
  local l_modem_dir_ap=
  local l_modem_out_dir_mp=
  local l_output_dir=
  local l_files_modem_dir_ap=
  local l_files_modem_out_dir_mp=
  local temp=
  
  
  if [ -z "$work_copy" ]; then
    work_copy=`pwd`
  fi
  if [ -z "$product_name" ] || [ -z "$output_dir" ] ; then
    echoTextRed "!!必须指定项目名称和输出目录"
    return
  fi
  if [ -n "$output_dir" ]; then
    mkdir -pv $output_dir
  fi
  product_name_lower=`echo $product_name |tr A-Z  a-z`
  l_output_dir=$work_copy/out/target/product/$product_name/
  echoTextBlue  "开始拷贝高通镜像文件to $output_dir ......"
  
  
  #处理modem部分
  echoTextRed "1.处理modem部分文件......."
  l_modem_dir_ap=$work_copy/vendor/bbk/product/$project_name/radio
  l_files_modem_dir_ap="fat.bin"
  for i in $l_files_modem_dir_ap;do
	cp -rvfL $l_modem_dir_ap/$i $output_dir
  done
  
  temp=`ls -p $work_copy/../  | grep "/" | grep "modem"`
  echo "temp=$temp"
  if [ -n "$temp" ]; then
	temp=`sh_menu_select2 "$temp"`
	temp=$work_copy/../$temp
	l_modem_out_dir_mp=$temp/
  else
    echoTextRed "找不到$work_copy/../目录下存在modem代码"
  fi
  echo "l_modem_out_dir_mp=$l_modem_out_dir_mp"

  
  
  #处理框架部分
  echoTextRed "1.处理框架部分文件......."

}


function sh_fetion_compile_results()
{
  local scd=true
  local work_copy=$1
  local product_name=$2
  automake_test_cmd=`which automake-test.sh`
  fetion_dir=`dirname $automake_test_cmd`/backup/fetion
  local work_copy_name=`basename $work_copy`
  local l_msg=
  local start_time=
  local end_time=
  local l_time=`sh_get_date_and_time`
  local current_time=`sh_get_time2`
#给一下人员发送短信
fx_mohuifu=13632795674
#fx_madongmei=13826579897
#fx_pengye=13424806075
#fx_xiaoxixiang=13790315876
#fx_wuquan=15816939584
#fx_pengfuhui=13480087450
#fx_lijinzhao=15002099567
#fx_bbk=13423357157
#给以上人员发送短信
  #dst_list=`cat $0 | grep ^fx_ | awk -F"=" '{print $2}' | tr '\n' ','`
  #dst_list=`echo ${dst_list%,*}`
  dst_list1="13632795674,13423357157"  #普通用户
  dst_list2="13632795674,13480087450,15816939584"  #管理员
  echo "$fetion_dir"
  if test -d $fetion_dir; then
    cd $fetion_dir
    export LD_LIBRARY_PATH=`pwd`

    if test -f $work_copy/out/target/product/$product_name/system.img; then
       echoTextGreen "编译成功......" 
       l_msg="${l_time}_编译${product_name}成功_框架:`cat $work_copy/.version`"
       l_msg="${l_msg}_应用:`cat $work_copy/packages/.version`"
       scd=true
       start_time=003000
       end_time=063000
       if [ $current_time -gt $start_time -a $current_time -lt $end_time ]; then
         if test -f $work_copy/.automake-test.ini; then
           parseini.shc $work_copy/.automake-test.ini set versions_info framework `cat $work_copy/.version`
           parseini.shc $work_copy/.automake-test.ini set versions_info app `cat $work_copy/packages/.version`
         else
           touch $work_copy/.automake-test.ini
           parseini.shc $work_copy/.automake-test.ini add versions_info framework `cat $work_copy/.version`
           parseini.shc $work_copy/.automake-test.ini add versions_info app `cat $work_copy/packages/.version`
         fi
       else
         echo ""
       fi
    else
       echoTextRed "有错误发生......"
       l_msg="${l_time}_编译${product_name}出错_框架:`cat $work_copy/.version`"
       l_msg="${l_msg}_应用`cat $work_copy/packages/.version`"
       scd=false
       cat $work_copy/out/target/product/*log*  |grep -E  "错误|\ error" -n
    fi
    start_time=083000
    end_time=223000
    if [ $current_time -gt $start_time -a $current_time -lt $end_time ] && [ "$scd" = "true" ]; then
      echo "./fetion --mobile=13632795674 --pwd=bbk123456 --to=$dst_list1 --msg-utf8=\"$l_msg\""
      ./fetion --mobile=13632795674 --pwd=bbk123456 --to=$dst_list1 --msg-utf8=\"$l_msg\"
    else
      echo "./fetion --mobile=13632795674 --pwd=bbk123456 --to=$dst_list2 --msg-utf8=\"$l_msg\""
      ./fetion --mobile=13632795674 --pwd=bbk123456 --to=$dst_list2 --msg-utf8=\"$l_msg\"
    fi
    cd -
  fi
}




